package com.gec.shop;

import java.io.Serializable;
import java.util.Scanner;

public class Staff implements Serializable {
    private int id;//员工id
    private  String password;//员工密码
    private  String name;//员工名称
    private  String sex;//员工性别
    private  long phone;//员工手机号
    private String post;//员工职位
    public Staff(int id,String password,String name,String sex,long phone,String post) {
        this.id = id;
        this.password = password;
        this.name = name;
        this.sex = sex;
        this.phone = phone;
        this.post = post;
    }
    public Staff(){};
    public static Object staffRegister(Scanner scanner) {
        Staff staff = new Staff();
        while(true){
            try {
                System.out.println("请输入注册密码->");
                staff.setPassword(scanner.next());
                System.out.println("请输入姓名->");
                staff.setName(scanner.next());
                System.out.println("请输入性别->");
                staff.setSex(scanner.next());
                System.out.println("请输入职位->");
                staff.setPost(scanner.next());
                System.out.println("请输入手机号(11位)->");
                String phone = scanner.next();
                if (phone.length() == 11) {
                    staff.setPhone(Long.parseLong(phone));
                    return staff;
                } else {
                    System.out.println("手机号格式不正确!");
                }
            }catch (Exception e){
                System.out.println("注册格式不正确!!!");
            }
        }
    }
    public static Staff staffLogin(Scanner scanner){
        Staff staff = new Staff();

        while(true){
            try {
                System.out.print("请输入登录ID->");
                staff.setId(scanner.nextInt());
                System.out.print("请输入密码->");
                staff.setPassword(scanner.next());
                return staff;
            }catch (Exception e){
                System.out.println("请输入正确的格式!!!");
                scanner.next();
            }
        }
    }
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public long getPhone() {
        return phone;
    }

    public void setPhone(long phone) {
        this.phone = phone;
    }

    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }
}
